<template>
  <div>
    <div class="header">
    <van-nav-bar class="nav_bar">
      <template #left>
        <van-icon name="arrow-left" size="18" color="white" />
      </template>
      <template #title>
        <van-search
          placeholder="请输入搜索关键词"
          class="vue_search"
          :label="text"
          left-icon="search"
          @click="goCityList"
        />
      </template>
      <template #right>
        <van-icon name="location-o" size="18" color="white" @click="$router.push('/map')" />
      </template>
    </van-nav-bar>


      <van-swipe :autoplay="3000" class="imgbox">
        <van-swipe-item v-for="(image, index) in images" :key="index">
          <img v-lazy="image" class="imglazy" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="leader">
      <van-grid :border="false" >
        <van-grid-item icon="wap-home-o" text="整租"  />
        <van-grid-item icon="friends-o" text="合租" />
        <van-grid-item icon="location-o" text="地图找房" />
        <van-grid-item icon="home-o" text="去出租" />
      </van-grid>
    </div>

<div class="footer">
<div class="groups"><span>租房小组</span> <a href=" ">更多 </a></div>
<div class="groupBox">
    <div class="box">
    <div v-for="item in list" :key="item.id" class="minibox">
     <img :src="`http://liufusong.top:8080${item.imgSrc}`" alt="" />
    <div class="right">
   <div>{{ item.title }}</div>
  <div>{{ item.desc }}</div>
 </div>
  </div>
    </div>
  </div>
 </div>
  </div>


</template>

<script>
import { groups } from '@/api/index'
export default {
  name: 'Index',
  props: {},
  data () {
    return {
      value: '',
      imagerender: [],
      images: [
        'http://liufusong.top:8080/img/swiper/1.png',
        'http://liufusong.top:8080/img/swiper/2.png',
        'http://liufusong.top:8080/img/swiper/3.png'
      ],
      list:{},
      text:localStorage.getItem('text') || '上海',
    }
  },

 async created () { 
const { data } = await groups()
 this.list = data.body
 localStorage.setItem('text','上海')
 },
 methods:{
goCityList () {
      this.$router.push({
        name: 'cityList',
        query: {
          text: this.text
        }
      })
    }
 }
}
</script>

<style scoped lang="less">
// .nav_bar {
//   position: fixed;
//   top: 5%;
//   left: 20%;
//   z-index: 9999;
//   .vue_search {
//     width: 200px;
//     height: 30px;
//     padding: 0;
//    /deep/ .van-icon-search{
//     color: #ccc;
//     }
//     .van-search__content {
//       width: 100%;
//       height: 30px;
//       padding-left: 0px;
//     }
//   }
// }
.nav_bar {
    position: fixed;
  top: 5%;
  left: 10%;
  z-index: 9999;
  // background-color: #23d881;
  /deep/ .van-nav-bar__title {
    max-width: 100%;
  }
}
.vue_search {
  flex: 1;
  width: 300px;
  height: 46px;
  // background-color: #23d881;
  z-index: 999;
  /deep/ .van-icon-search {
    color: #ccc;
    border-left: 1px solid #ccc;
    padding-left: 10px;
  }
}

.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
}
.imglazy {
  width: 100%;
  height: 212px;
}
.footer {
 display: inline-block;
 height: 200px;
  width: 355px;
 background-color: #f6f5f6;
 overflow: hidden;
 padding: 0 10px;
 .groups {
  display: flex;
  justify-content: space-between;
  margin: 15px 0 15px 10px;
  font-size: 15px;
 }
}
.box {
 display: flex;
 justify-content: start;
 flex-wrap: wrap;
 margin-top: 20px;

.minibox {
 display: flex;
  justify-content: start;
 width: 165px;
 height: 60px;
 margin-bottom: 10px;
 margin-left: 10px;
 background-color: #fff;
 font-size: 14px;
  }
 img {
 width: 50px;
 height: 50px;
  margin: 0 10px;
 }
 .right {
 margin-top: 10px;
  }
}
</style>
